home *** CD-ROM | disk | FTP | other *** search
-
-
- Listing 6:
-
- /* complex hyperbolic sine routine intended to test
- argument passing and function returns only. This
- version uses a macro following Louis Baker's method
- covered in "Complex Arithmetic and Matrices in C,"
- the C Users Journal, May, 1990 */
-
- #include <dos.h>
- #include <math.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
-
- #define BIOS_DATA_SEG 0x40
- #define TIMER_DATA 0x6c
- #define TICKS_PER_DAY 0x01800B0L
- #define CSINH(y, x) {y.real = cos(x.imag)
- * sinh(x.real);\ y.imag = sin(x.imag)
- * cosh(x.real);}
-
- struct cmplx_nmbr
-
- {
- double real;
- double imag;
- };
-
- long getticks(void);
-
- main()
-
- {
- int ctr;
- long start, end;
- struct cmplx_nmbr arg, rtrn;
- start = getticks();
- printf("\n BEGIN AT CLOCK = %ld", start);
- arg.real = 3.0;
- arg.imag = -2.0;
- for(ctr = 1; ctr <= 5000; ++ctr)
- CSINH(rtrn, arg);
-
- printf("\n\n REAL RESULT = %lG", rtrn.real);
- printf(" IMAG RESULT = %lG", rtrn.imag);
- end = getticks();
- printf("\n END AT CLOCK = %ld", end);
- printf("\n\n ELAPSED TICKS = %ld", end - start);
- }
-
-